<?php

namespace App\Models;

use App\Models\airline\base\CompanyModel;
use App\Models\airline\base\FlightModel;
use App\Models\airline\base\PortModel;
use App\Models\airline\base\RouteModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model as BaseModel;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;


class FlightItemModel extends BaseModel
{
    use HasFactory, SoftDeletes;

    protected $table = 't_flight_item';

    protected $primaryKey = 'id';

    public $timestamps = false;

    const CREATED_AT = null;
    
    const UPDATED_AT = null;

    protected $guarded = [];

    protected $hidden = [
        'deleted_at',
    ];

    //航线
    public function route(): BelongsTo {
        return $this->belongsTo(RouteModel::class, 'route_id');
    }

    //始发港
    public function start_port(): BelongsTo {
        return $this->belongsTo(PortModel::class, 'start_port_id');
    }

    //目的地国家
    public function destination(): BelongsTo {
        return $this->belongsTo(CountryModel::class, 'destination_id');
    }

    //抵达港
    public function arrive_port(): BelongsTo {
        return $this->belongsTo(PortModel::class, 'arrive_port_id');
    }

    //航司
    public function air_company(): BelongsTo {
        return $this->belongsTo(CompanyModel::class, 'airline_company_id');
    }

    //航班
    public function air_line(): BelongsTo {
        return $this->belongsTo(FlightModel::class, 'airline_flight_id');
    }

}
